//
//  LXAddLabView.m
//  ZuLinProject
//
//  Created by bancheng on 2022/11/7.
//  Copyright © 2022 LX_App. All rights reserved.
//

#import "LXAddLabView.h"

@implementation LXAddLabView

- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.6];
    
    
    [self.backView addCorner:10];
    
    [self.textField addCorner:3];
    self.textField.delegate = self;
    self.textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 0)];
    self.textField.leftViewMode = UITextFieldViewModeAlways;

    
    
    
    [self.cancelBtn addCorner:4];
    [self.confirmBtn addCorner:4];
    
}
- (IBAction)closeAction:(UIButton *)sender {
    [self removeFromSuperview];
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    

    [ChineseNotificationHelp ChineseNotificationHelpShareWithTextFiled:textField WithMaxLength:4];
    return YES;
    
}
- (IBAction)cancelAction:(UIButton *)sender {
    
    if ([self.cancelBtn.titleLabel.text containsString:@"删除"]) {
        if (self.clickCancelBlock) {
            self.clickCancelBlock(self.textField.text);
        }
    }
    [self removeFromSuperview];
}
- (IBAction)confirmAction:(UIButton *)sender {
    
    if (StringIsEmpty(self.textField.text)) {
        showAlert(@"请输入标签");
        return;
    }
    
    if (self.clickConfirmBlock) {
        self.clickConfirmBlock(self.textField.text);
    }
    
    
    [self removeFromSuperview];
    
}

@end
